<template>
  <base-breadcrumb :title="$route.meta.title">
    <!-- 汇总评价 -->
    <a-form-model ref="ruleForm" :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }" :rules="editModel != 0 ? rules : {}" id="base-breadcrumb" style="position: relative">
      <a-spin :spinning="loading[0] || loading[1]">
        <!-- 表格 -->
        <a-card :bordered="false" class="cumtom-card">
          <title-name title="基本信息"></title-name>
          <custom-form 
              :formList="formList1" 
              :form="form" 
              :editModel="onlyRead ? 'V' : 'E'"
              @getProjectInfo="getProjectInfo"
            >
            </custom-form>
        </a-card>
        <a-card :bordered="false" class="cumtom-card">
          <title-name title="过程检查与考核评价"></title-name>
          <div style="padding-left: 20px;">
            <a-button type="primary" v-if="editModel != 0" @click="handleAddProcessYears" style="margin-bottom: 20px;">增行</a-button>
            <a-table
              :rowKey="(record, index) => index"
              :dataSource="form.processYears"
              :columns="columnsProcessYears"
              bordered
              :pagination="false"
              style="margin-bottom: 20px;"
            >
              <template slot="gradeYear" slot-scope="text, record, index">
                <span v-if="onlyRead">{{ record.gradeYear }}</span>
                <a-date-picker
                  v-model="record.gradeYear"
                  mode="year"
                  :allowClear="false"
                  v-else
                  format="YYYY"
                  class="requiredFormItem"
                  placeholder="请选择"
                  :open="record.yearPickShow"
                  @panelChange="(e) => handlePanelChange(e, index)"
                  @openChange="(e) => handleOpenChange(e, index)"
                />
              </template>
              <!-- 过程检查得分 -->
              <template slot="processScore" slot-scope="text, record, index">
                <div v-if="editModel != 0">
                  <a-row type="flex" :gutter="10" style="flex-wrap: nowrap">
                    <a-input 
                      style="width: 100%"
                      placeholder="自动带出"
                      disabled
                      v-model="record.processScore"
                    />
                    <a-button class="ml12" type="primary" @click="handleSelectYearAverage(index, '0') ">选择</a-button>
                  </a-row>
                </div>
                <span v-else>{{ text }}</span>
              </template>
              <!-- 年度考核得分 -->
              <template slot="yearScore" slot-scope="text, record, index">
                <div v-if="editModel != 0">
                  <a-row type="flex" :gutter="10" style="flex-wrap: nowrap">
                    <a-input 
                      style="width: 100%"
                      placeholder="自动带出"
                      disabled
                      v-model="record.yearScore"
                    />
                    <a-button class="ml12" type="primary"  @click="handleSelectYearAverage(index, '1')">选择</a-button>
                  </a-row>
                </div>
                <span v-else>{{ text }}</span>
              </template>
              <!-- 综合得分（过程检查70%+年度考核（30%）） -->
              <template slot="compositeScore" slot-scope="text, record">
                <a-input
                  v-if="editModel != 0"
                  style="width: 100%"
                  placeholder="自动计算得出"
                  disabled
                  v-model="record.compositeScore"
                />
                <span v-else>{{ text }}</span>
              </template>
              <!-- 操作栏 -->
              <template slot="actions" slot-scope="text, record, index">
                <a @click="handleDeleteProcessYears({ record, index })">删除</a>
              </template>
            </a-table>
            <div class="flex">
                <span>平均得分：</span>
                <a-input v-if="editModel != 0" v-model="processYearAverageTotal" placeholder="评价分" disabled style="width: 206px;" />
                <span v-else>{{ processYearAverageTotal }}</span>
            </div>
          </div>
        </a-card>
        <a-card :bordered="false" class="cumtom-card">
          <title-name title="竣工评价"></title-name>
          <div style="padding-left: 20px;">
            <a-button type="primary" v-if="editModel != 0" @click="handleFinishGradeList()" style="margin-bottom: 20px;">选择</a-button>
            <a-table
              :rowKey="(record, index) => record ? (record.id + index) : index"
              :dataSource="finishGradeList"
              :columns="columnsFinishGradeList"
              bordered
              :pagination="false"
              style="margin-bottom: 20px;"
            >
              <!-- 竣工评价得分 -->
              <template slot="percentileSystemScore" slot-scope="text, record">
                <div v-if="editModel != 0">
                  <a-input 
                      style="width: 100%"
                      placeholder="自动带出"
                      disabled
                      v-model="record.percentileSystemScore"
                    />
                </div>
                <span v-else>{{ text }}</span>
              </template>
              <!-- 评价人 -->
              <template slot="gradeEmployeeName" slot-scope="text, record">
                <div v-if="editModel != 0">
                  <a-input 
                      style="width: 100%"
                      placeholder="自动带出"
                      disabled
                      v-model="record.gradeEmployeeName"
                    />
                </div>
                <span v-else>{{ text }}</span>
              </template>
              <!-- 评价时间 -->
              <template slot="fillerDate" slot-scope="text, record">
                <div v-if="editModel != 0">
                  <a-input 
                      style="width: 100%"
                      placeholder="自动带出"
                      disabled
                      v-model="record.fillerDate"
                    />
                </div>
                <span v-else>{{ text }}</span>
              </template>
              <!-- 操作栏 -->
              <template slot="actions" slot-scope="text, record, index">
                <a @click="handleDeleteFinishGradeList({ record, index })">删除</a>
              </template>
            </a-table>
            <div class="flex">
                <span>平均得分：</span>
                <a-input v-if="editModel != 0" v-model="finishAverageTotal" placeholder="评价分" disabled style="width: 206px;" />
                <span v-else>{{ finishAverageTotal }}</span>
            </div>
          </div>
        </a-card>
        <a-card :bordered="false" class="cumtom-card">
          <title-name title="综合得分"></title-name>
          <div style="padding-left: 20px;">
            <div class="flex">
                <span>综合得分：</span>
                <a-input v-if="editModel != 0" v-model="compositeScoreTotal" placeholder="自动计算得出" disabled style="width: 206px;" />
                <span v-else>{{ compositeScoreTotal }}</span>
            </div>
          </div>
        </a-card>
        <a-card :bordered="false" class="cumtom-card">
          <title-name title="评价组成员"></title-name>
          <div style="padding-left: 20px;">
            <div class="mb12" v-if="editModel != 0">
              <a-button type="primary" icon="plus" @click="$refs['dialogEdit'] && $refs['dialogEdit'].open()"
                >添加人员</a-button
              >
              <a-button class="ml12" :disabled="!selectedRowKeysMembers.length" icon="delete" @click="handleDeleteMembers(0)"
                >移除</a-button
              >
            </div>
            <a-table
              rowKey="userId"
              :row-selection="editModel != 0 ? { selectedRowKeys: selectedRowKeysMembers, onChange: onSelectChangeMembers } : null"
              :dataSource="form.members"
              :columns="columnsMembers"
              bordered
              :pagination="false"
            >
              <!-- 组内分工 -->
              <template slot="groupCode" slot-scope="text, record, index">
                <div v-if="onlyRead">{{ options[record.groupCode].name }}</div>
                <template v-else>
                  <div class="requiredFormItem">
                    <a-select  v-model="record.groupCode" placeholder="请选择组内分工">
                      <a-select-option v-for="item in options" :key="item.id" :value="item.id">{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </div>
                </template>
              </template>
              <!-- 备注 -->
              <template slot="remarks" slot-scope="text, record">
                <div v-if="onlyRead">{{ text }}</div>
                <BaseInput v-else v-model="record.remarks" />
              </template>
              <!-- 操作栏 -->
              <template slot="actions" slot-scope="text, record, index">
                <a @click="handleDeleteMembers(1, { record, index })">移除</a>
              </template>
            </a-table>
          </div>
          
        </a-card>
      </a-spin>
    </a-form-model>
    <!-- 页脚操作栏 -->
    <div class="btn_box page-btn-right-top" v-if="!isFromAudit">
      <a-button :loading="loading[0]" :disabled="loading[1]" v-if="editModel != '0'" type="primary" class="button_right" @click="handleSubmit(0)">保存草稿</a-button>
      <a-button :loading="loading[1]" :disabled="loading[0]" v-if="editModel != '0'" type="primary" class="button_right" @click="handleSubmit(1)">提交</a-button>
      <a-button type="primary" @click="$multiTab.close()">关闭</a-button>
    </div>
    <div v-if="!isConsultation && isFromAudit" class="page-btn-right-top">
      <a-button
        v-check-visible-in-detail
        style="margin: 0 10px"
        @click="$close"
      >
        关闭
      </a-button>
    </div>
    <ChooseYearAverage :visible="visibleYearAverage" :info="yearAverageObj" @closeModal="visibleYearAverage = false" @handleConfirm="handleConfirmYearAverage" />
    <ChooseFinishGradeList :visible="visibleFinishGradeList" :info="finishGradeListObj" @closeModal="visibleFinishGradeList = false" @handleConfirm="handleConfirmFinishGradeList" />
    <SelectPerson
      :ref="'dialogEdit'"
      header-title="添加人员"
      :form="{ whether: false }"
      :selectData="form.members || []"
      @confirm="handleAddMembers"
      :checkStrictly="true"
    />
    <selectApprover :businessId="businessId"  :processConfig="setProcessConfig"></selectApprover>
  </base-breadcrumb>
</template>

<script>
import BaseEditPage from '@/views/baseEditPage' // 编辑详情页基础配置
import ChooseYearAverage from './ChooseYearAverage' // 编辑详情页基础配置
import ChooseFinishGradeList from './ChooseFinishGradeList' // 编辑详情页基础配置
import { riskGradeGather } from '@/api/quality/riskGrade' // api
import moment from 'moment'
export default {
  name: 'a' + Date.now(),
  extends: new BaseEditPage(),
  components: {
    SelectPerson: () => import('@/components/BComponents/BSelectPerson'),
    ChooseYearAverage,
    ChooseFinishGradeList,
  },
  props: {
      // 是否作为意见征询
      isConsultation: {
        type: Boolean,
        default: false
      }
    },
  data() {
    return {
      visibleYearAverage: false,
      yearAverageObj: {
        index: '',
        gradeYear: '',
        projectId: '',
        selectedRowKeys: [],
        typeCode: '', // 0 过程检查评分 1 年度考核评分 2 竣工评价
      },
      finishGradeListObj: {
        index: 0,
        gradeYear: '',
        projectId: '',
        selectedRowKeys: [],
        typeCode: '2', // 0 过程检查评分 1 年度考核评分 2 竣工评价
      },
      visibleFinishGradeList: false,
      loading: { 0: false, 1: false }, // 草稿和提交按钮loding:0 保存;1 提交
      editModel: 0, // 操作状态:0 查看;1 编辑;2 新增
      rules: {
        branchComId: [{ required: true, message: '请选择分公司', trigger: 'change' }],
        projectId: [{ required: true, message: '请选择项目', trigger: 'change' }],
        mainRisk: [{ required: true, message: '请输入项目存在的主要风险', trigger: 'change' }],
      },
      options: [
        {name: '组长', id: '0'},
        {name: '组员', id: '1'},
      ],
      selectedRowKeysMembers: [], // 选中人员id集合
      selectedRowMembers: [], // 选中人员列表
      visible: false, // 表单弹窗显隐控件
      finishGradeList: [],
      form: {
        viewName: '',
        fillerDate: '',
        fillerEmployeeId: '',
        mainRisk: '',
        branchComId: '',
        projectId: '',
        processYears: [],
        finishGradeIds: [],
        finishAverage: '',
        members: []
      }, // 表单参数
      isFromAudit: false, // 是否来自审批
      //获取流程配置值
      processConfig: null,
        //点击提交发送流程配置值
        setProcessConfig: null,
        businessId: null
    }
  },
  computed: {
    // 只读模式
    onlyRead() {
      return this.editModel == 0 || this.isFromAudit
    },
    finishAverageTotal() {
      if (this.finishGradeList.length > 0) {
        let list = this.finishGradeList
        let sum = 0;
        for (let i =0; i< list.length; i++) {
          sum += +list[i].percentileSystemScore || 0
        }
        return (sum / list.length).toFixed(2)
      }
      return 0.00
    },
    processYearAverageTotal() {
      if (this.form.processYears.length > 0) {
        let list = this.form.processYears
        let sum = 0;
        for (let i =0; i< list.length; i++) {
          sum += +list[i].compositeScore || 0
        }
        return (sum / list.length).toFixed(2)
      }
      return 0.00
    },
    compositeScoreTotal() {
      if (+this.finishAverageTotal || +this.processYearAverageTotal) {
        return (((+this.finishAverageTotal) + (+this.processYearAverageTotal))/2).toFixed(2)
      } else {
        return 0.00
      }
    },
    // 表单列表
    formList1() {
      return [
        {
          label: '所属单位',
          type: 'orgTree',
          keyName: 'projectId',
          rules: [{ required: true, message: '请选择项目名称', trigger: 'change' }],
          isAutoSelectFirst: this.editModel == 2,
          isNeedAuth:true ,
          checkStrictly: true,
          disabled: this.editModel != '2',
          isNoBorder: this.editModel == '0',
          viewName: "viewName",
        },
        {
          keyName: 'mainRisk',
          viewName: 'mainRisk',
          type: 'a-textarea',
          label: '项目存在的主要风险',
          span: 24,
          attrs: {
            maxLength: 1000
          },
          rules: {

          }
        },
        {
          keyName: 'fillerEmployeeName',
          type: 'a-input',
          disabled: true,
          label: '填报人'
        },
        {
          keyName: 'fillerDate',
          type: 'a-date-picker',
          disabled: true,
          label: '填报时间',
          attrs: {
            valueFormat: 'YYYY-MM-DD'
          }
        }
      ]
    },
    columnsMembers() {
      let list = [
        {
          title: '姓名',
          ellipsis: true,
          dataIndex: 'name'
        },
        {
          title: '职称',
          ellipsis: true,
          dataIndex: 'titleName',
          customRender(e) {
            return e || '无'
          }
        },
        {
          title: '岗位',
          ellipsis: true,
          dataIndex: 'postName',
          customRender(e) {
            return e || '无'
          }
        },
        {
          title: '学历',
          ellipsis: true,
          dataIndex: 'education',
          customRender(e) {
            return e || '无'
          }
        },
        {
          title: '组内分工',
          scopedSlots: { customRender: 'groupCode' },
          dataIndex: 'groupCode'
        },
        {
          title: '备注',
          scopedSlots: { customRender: 'remarks' },
          dataIndex: 'remarks'
        },
      ]
      if (this.editModel != 0) {
        list.push({
          title: '操作',
          dataIndex: 'actions',
          width: '100px',
          align: 'center',
          scopedSlots: { customRender: 'actions' }
        })
      }
      return list
    },
    columnsFinishGradeList() {
     let list = [
        {
          title: '序号',
          width: '80px',
          customRender(text, record, index) {
            return index + 1
          }
        },
        {
          title: '竣工评价得分',
          dataIndex: 'percentileSystemScore',
          scopedSlots: { customRender: 'percentileSystemScore' }
        },
        {
          title: '评价人',
          dataIndex: 'gradeEmployeeName',
          scopedSlots: { customRender: 'gradeEmployeeName' }
        },
        {
          title: '评价时间',
          dataIndex: 'fillerDate',
          scopedSlots: { customRender: 'fillerDate' }
        },
     ]
     if (this.editModel != 0) {
        list.push({
          title: '操作',
          dataIndex: 'actions',
          width: '100px',
          align: 'center',
          scopedSlots: { customRender: 'actions' }
        })
     }
     return list
    },
    columnsProcessYears() {
     let list = [
        {
          title: '序号',
          width: '80px',
          customRender(text, record, index) {
            return index + 1
          }
        },
        {
          title: '年度',
          dataIndex: 'gradeYear',
          scopedSlots: { customRender: 'gradeYear' }
        },
        {
          title: '过程检查得分',
          dataIndex: 'processScore',
          scopedSlots: { customRender: 'processScore' }
        },
        {
          title: '年度考核得分',
          dataIndex: 'yearScore',
          scopedSlots: { customRender: 'yearScore' }
        },
        {
          title: '综合得分（过程检查70%+年度考核（30%））',
          dataIndex: 'compositeScore',
          scopedSlots: { customRender: 'compositeScore' }
        },
     ]
     if (this.editModel != 0) {
      list.push({
          title: '操作',
          dataIndex: 'actions',
          width: '100px',
          align: 'center',
          scopedSlots: { customRender: 'actions' }
        })
     }
     return list
    },
  },
  async created() {
    this.$route.meta.title = ['汇总评价查看', '汇总评价编辑', '汇总评价新增'][this.editModel]
    // 为添加操作时
    if (this.editModel == 2) {
      this.form.fillerEmployeeName = this.$userInfo()?.name
      this.form.fillerEmployeeId = this.$userInfo()?.employee?.id
      this.form.fillerDate = this.$dateFormat(new Date(), 'D')
    }
    this.isFromAudit = !!this.$route.query.businessId
    if (this.id) {
      this.init()
    }
    //获取通过获取流程配置值
    this.processConfig = await this.$getConfigFn('quality_risk_grade_gather')
  },
  methods: {
    init() {
      let args = {}
      if (this.id) {
        args.id = this.id
      }
      this.loading[0] = true
      return riskGradeGather
        .getDetail(args)
        .then((res) => {
          if (res.data) {
            this.loading[0] = false
            // 映射项目信息
            let data = res.data
            if (data) {
              if (data.finishGrades) {
                this.finishGradeList = data.finishGrades.map(item => {
                  item.percentileSystemScore = +item.score || 0 
                  return item
                })
              }
              data.viewName = data.branchComName + '/' + data.projectName
              data.members = data.members || []
              data.processYears = data.processYears || []
              data.finishGradeIds = data.finishGradeIds || []
              this.form = data
            }
          }
        })
        .catch((res) => {
          this.loading[0] = false
        })
    },
    /**
     * 表格复选
     * @param {Array}} selectedRowKeys -选中值集合
     */
     onSelectChangeMembers(selectedRowKeys, selectedRow) {
      this.selectedRowKeysMembers = selectedRowKeys
      this.selectedRowMembers = selectedRow
    },
    //获取项目详情
    getProjectInfo(e) {
        this.$set(this.form, 'branchComId', e.branchId)
    },
    /**
     * 添加人员
     * @param {Array}} e -选中人员
     */
     handleAddMembers(e) {
      let members = e.map((i) => ({
        personId: i.userId,
        userId: i.userId,
        name: i.name,
        titleName: i.jobTitle,
        postName: i.postPNames?.join('，'),
        education: i.specialitieMax || i.firstEducation, // 最高 || 第一学历
        groupCode: this.form.members.filter(item => item.userId == i.userId).length > 0 ? this.form.members.filter(item => item.userId == i.userId)[0].groupCode : ''
      }))
      this.form.members = members
    },
    /**
     * 删除行详情
     * @param {Number} type -删除类型：0 选中，1 当前行
     * @param {Object} e -当前行对象
     */
     handleDeleteMembers(type, e) {
      this.$confirm({
        title: '温馨提示',
        content: `确定删除${type === 1 ? e.record.name : this.selectedRowMembers?.map((i) => i.name).join('，')}？`,
        onOk: () => {
          if (type === 1) {
            this.form.members.splice(e.index, 1)
          } else {
            this.form.members = this.form.members.filter((i) => !this.selectedRowKeysMembers.includes(i.userId))
            this.selectedRowMembers = []
            this.selectedRowKeysMembers = []
          }
        }
      })
    },
    handleOpenChange(status, index) {
      this.$set(this.form.processYears[index], 'yearPickShow', status)
    },
    handlePanelChange(value, index) {
      const year = moment(value).format("YYYY");
      if(this.form.processYears[index].gradeYear!=year){
        this.$set(this.form.processYears[index], 'processScore', null)
        this.$set(this.form.processYears[index], 'yearScore', null)
        this.$set(this.form.processYears[index], 'compositeScore', null)
      }
      this.$set(this.form.processYears[index], 'gradeYear', year)
      this.$set(this.form.processYears[index], 'yearPickShow', false)
      // this.$nextTick(() => {
      //   this.$refs.ruleForm?.validateField('gradeYear')
      // })
    },
    handleDeleteProcessYears(e) {
      this.$confirm({
        title: '温馨提示',
        content: `确定删除？`,
        onOk: () => {
          this.form.processYears.splice(e.index, 1)
        }
      })
    },
    handleAddProcessYears() {
      this.form.processYears.push({
        gradeYear: '',
        processGradeId: '',
        processScore: '',
        yearGradeId: '',
        yearScore: '',
        compositeScore: '',
      })
    },
    handleConfirmYearAverage(obj) {
      if (obj && obj.rows && obj.rows.length > 0) {
        let row = obj.rows[0]
        let index = obj.index
        if (obj.typeCode == '0') {
          // 过程检查评分
          this.form.processYears[index].processScore = row.percentileSystemScore
          this.form.processYears[index].processGradeId = row.id
        } else if (obj.typeCode == '1') {
          // 年度考核评分
          this.form.processYears[index].yearScore = row.percentileSystemScore
          this.form.processYears[index].yearGradeId = row.id
        }
        if (!!this.form.processYears[index].processScore && !!this.form.processYears[index].yearScore) {
          this.form.processYears[index].compositeScore = ((+this.form.processYears[index].processScore * 0.7) 
          + (+this.form.processYears[index].yearScore * 0.3)).toFixed(2)
        }
      }
    },
    handleSelectYearAverage(index, typeCode) {
      if (!!!this.form.projectId) {
        this.$message.warning(`请先选择项目`)
        return false
      }
      if (!!!this.form.processYears[index].gradeYear) {
        this.$message.warning(`请先选择第${index + 1}行年度！`)
        return false
      }
      this.yearAverageObj = {
        index,
        typeCode,
        gradeYear: this.form.processYears[index].gradeYear,
        projectId: this.form.projectId,
        selectedRowKeys: typeCode == '0' ? this.form.processYears.map(item => item.processGradeId) :  this.form.processYears.map(item => item.yearGradeId),
      }
      this.visibleYearAverage = true
    }, 
    handleDeleteFinishGradeList(e) {
      this.$confirm({
        title: '温馨提示',
        content: `确定删除？`,
        onOk: () => {
          this.finishGradeList.splice(e.index, 1)
        }
      })
    },
    handleConfirmFinishGradeList(obj) {
      if (obj && obj.rows && obj.rows.length > 0) {
        this.finishGradeList = obj.rows
      }
    },
    handleFinishGradeList() {
      this.finishGradeListObj = {
        selectedRowKeys: this.finishGradeList.map(item => item.id),
        projectId: this.form.projectId
      }
      this.visibleFinishGradeList = true 
    },
    /**
     * 操作栏 type:0 新增;1 编辑
     */
    handleManage(type, record) {
      this.editModel = type // 映射操作类型
      this.form = type == 1 ? this.$clone(record) : {} // 配置参数
      this.visible = true // 打开表单
    },
    submit(statusCode) {
      this.setProcessConfig = null;
      this.loading[statusCode] = true
      let form = this.$clone(this.form)
      form.status = statusCode ? 'SUBMITTED' : 'DRAFT'
      form.finishGradeIds = this.finishGradeList.map(item => item.id)
      form.finishAverage = this.finishAverageTotal
      form.processYearAverage = this.processYearAverageTotal
      form.compositeScore = this.compositeScoreTotal
      let name = ['create', 'update'][this.id ? 1 : 0] // 根据操作切换url地址
      riskGradeGather[name](form)
        .then((res) => {
          this.loading[statusCode] = false
          this.$message.success(['保存', '提交'][statusCode] + '成功！')
          if (statusCode) {
            this.businessId = res.data.id;
            this.setProcessConfig = this.processConfig;
            return
          }
          this.$multiTab.close()
        })
        .catch((res) => {
          this.loading[statusCode] = false
        })
    },
    /**
     * 提交表单
     */
    handleSubmit(statusCode) {
      // 校验表单
      this.$refs.ruleForm.validate((e) => {
        if (e) {
          if (statusCode) {
            let processYears = this.form.processYears
            if (processYears.length === 0) {
              this.$message.warning(`请完成过程检查与考核评价！`)
              return false
            }
            for (let index = 0;index<processYears.length;index++) {
              if (!!!processYears[index].compositeScore || !!!processYears[index].gradeYear) {
                this.$message.warning(`请完成第${index + 1}行过程检查与考核评价！`)
                return false
              }
            }
            let finishGradeList = this.finishGradeList
            if (finishGradeList.length === 0) {
              this.$message.warning(`请完成竣工评价！`)
              return false
            }
            for (let index = 0;index<finishGradeList.length;index++) {
              if (!!!finishGradeList[index].percentileSystemScore) {
                this.$message.warning(`请完成第${index + 1}行竣工评价！`)
                return false
              }
            }
            let members = this.form.members
            if (members.length === 0) {
              this.$message.warning(`请完成评价组成员！`)
              return false
            }
            for (let index = 0;index<members.length;index++) {
              if (!!!members[index].groupCode) {
                this.$message.warning(`请完成第${index + 1}行评价组成员！`)
                return false
              }
            }
            let groupCode0 = -1
            let groupCode1 = -1
            for (let index = 0;index<members.length;index++) {
              if (members[index].groupCode == '0') {
                groupCode0 = index
              }
              if (members[index].groupCode == '1') {
                groupCode1 = index
              }
            }
            if (groupCode0 === -1 || groupCode1 === -1) {
              this.$message.warning(`必须包含组长和组员！`)
              return false
            }
            if (this.processConfig == 4) {
              this.submit(statusCode)
            } else {
              // 提交表单
              this.$confirm({
                title: '温馨提示',
                content: `确定${['保存', '提交'][statusCode]}!`,
                onOk: () => {
                  this.submit(statusCode)
                }
              })
            }
          } else {
            this.submit(statusCode)
          }
          
        }
      })
    },
  },
}
</script>

<style lang="less" scoped>
  .cumtom-card {
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
  }
</style>